<template>
    <div>
        添加分类
        <van-cell-group>
        <van-field v-model="cour.name" label="文本" placeholder="请输入分类名称" />
        <van-field v-model="cour.pid" label="文本" placeholder="请输入父级id" />
        <van-field v-model="cour.params" label="文本" placeholder="请输入参数配置" />
        <van-button @click="add">添加</van-button>
        </van-cell-group>

        分类展示
        <table>
            <tr>
                <td>id</td>
                <td>分类名称</td>
                <td>父级分类</td>
                <td>参数配置</td>
            </tr>
            <tr v-for="i in frm">
                <td>{{i.id}}</td>
                <td>{{i.name}}</td>
                <td>{{i.pid}}</td>
                <td>{{i.params}}</td>
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                frm:{},
                cour:{},
            }
        },
        methods:{
            get_course(){
                this.$axios.get('/course/cateM').then(res=>{
                    this.frm = res.data.list
                })
            },
            add(){
                this.$axios.post('/course/cateM',this.cour).then(res=>{
                    if(res.data.code==200){
                        alert('添加成功')
                        this.get_course()
                    }else{
                        alert('添加失败')
                    }
                })
            }
        },
        mounted(){
            this.get_course()
        }
    }
</script>

<style scoped>

</style>